// app.js
App({
  onLaunch() {
    // navigator
    let menuButtonObject = wx.getMenuButtonBoundingClientRect();
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        console.log(res)
      },
      fail: res => {

      }
    })
    wx.getSystemInfo({
      success: res => {
        let statusBarHeight = res.statusBarHeight,
          navTop = menuButtonObject.top,//胶囊按钮与顶部的距离
          navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top - statusBarHeight)*2;//导航高度
        this.globalData.navHeight = navHeight;
        this.globalData.navTop = navTop;
        this.globalData.windowHeight = res.windowHeight;
        if (res.model.search('iPhone X') != -1){ //IPhoneX底部大约为68rpx
          this.globalData.isIphoneX = true;
        }else{
          this.globalData.isIphoneX = false;
        }
      },
      fail(err) {
        // console.log(err);
      }
    })
  },
  globalData: {
    userInfo: null,
    loginState: true,
    // 接口
    testApi:"http://www.publishboard.net/apis",
    // testApi:"https://bodao.mhuoba.com/apis"
  }
})